package cn.edu.nuc.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.nuc.crm.dao.ApplicationMapper;
import cn.edu.nuc.crm.dto.PageInfo;
import cn.edu.nuc.crm.entity.Application;
import cn.edu.nuc.crm.entity.Product;
import cn.edu.nuc.crm.service.interfaces.ApplicationService;
@Service
public class ApplicationServiceImpl implements ApplicationService {
	@Autowired
	private ApplicationMapper applicationMapper;
	
	@Override
	public PageInfo pi(int current) {
		PageInfo pi = new PageInfo(current);
		int count = applicationMapper.getcount();
		pi.setCount(count);
		List<Application> findByid=applicationMapper.findByid(pi.getStart(), pi.getOffset());
		System.out.println("总的记录数:"+count+"--"+pi);
		pi.setList(findByid);
		return pi;
	}

	@Override
	public List<Application> selectByName(String aptTrueName) {
		// TODO Auto-generated method stub
		List<Application> result=applicationMapper.selectByName(aptTrueName);
		return result;
	}

	@Override
	public Application selectByPrimaryKey(Integer aptId) {
		// TODO Auto-generated method stub
		Application result=applicationMapper.selectByPrimaryKey(aptId);
		return result;
	}

	@Override
	public int deleteByPrimaryKey(Integer aptId) {
		// TODO Auto-generated method stub
		int result=applicationMapper.deleteByPrimaryKey(aptId);
		return result;
	}

	@Override
	public int insert(Application apt) {
		// TODO Auto-generated method stub
		int result=applicationMapper.insert(apt);
		return result;
	}

	@Override
	public PageInfo piStatus(int current,int status) {
		PageInfo pi = new PageInfo(current);
		int count = applicationMapper.getStatusCount(status);
		pi.setCount(count);
		List<Application> findByid=applicationMapper.findByidStatus(status,pi.getStart(), pi.getOffset());
		System.out.println("总的记录数:"+count+"--"+pi);
		pi.setList(findByid);
		return pi;
	}

	@Override
	public int update(Application application) {
		// TODO Auto-generated method stub
		int count = applicationMapper.updateByPrimaryKey(application);
		return count;
	}

	@Override
	public List<Application> findAll() {
		// TODO Auto-generated method stub
		List<Application> list = applicationMapper.findAll();
		return list;
	}

	@Override
	public PageInfo selectByCountId(int current,Integer accountid) {
		// TODO Auto-generated method stub
		PageInfo pi = new PageInfo(current);
		int count = applicationMapper.getCountId(accountid);
		pi.setCount(count);
		List<Application> findByid=applicationMapper.findCountId(accountid,pi.getStart(), pi.getOffset());
		System.out.println("总的记录数:"+count+"--"+pi);
		pi.setList(findByid);
		return pi;
	}

	@Override
	public int updateByPrimaryKeySelective(Application application) {
		// TODO Auto-generated method stub
		int count = applicationMapper.updateByPrimaryKeySelective(application);
		return count;
	}

}
